home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_libtool.idb / usr / freeware / info / libtool.info-2.z / libtool.info-2
Encoding:
GNU Info File  |  1999-07-16  |  47.5 KB  |  1,252 lines

  1. This is Info file libtool.info, produced by Makeinfo version 1.68 from
  2. the input file libtool.texi.
  3.  
  4. INFO-DIR-SECTION GNU programming tools
  5. START-INFO-DIR-ENTRY
  6. * Libtool: (libtool).           Generic shared library support script.
  7. END-INFO-DIR-ENTRY
  8.  
  9. INFO-DIR-SECTION Individual utilities
  10. START-INFO-DIR-ENTRY
  11. * libtoolize: (libtool)Invoking libtoolize.     Adding libtool support.
  12. END-INFO-DIR-ENTRY
  13.  
  14.    This file documents GNU Libtool 1.3.2
  15.  
  16.    Copyright (C) 1996-1999 Free Software Foundation, Inc.
  17.  
  18.    Permission is granted to make and distribute verbatim copies of this
  19. manual provided the copyright notice and this permission notice are
  20. preserved on all copies.
  21.  
  22.    Permission is granted to copy and distribute modified versions of
  23. this manual under the conditions for verbatim copying, provided that the
  24. entire resulting derived work is distributed under the terms of a
  25. permission notice identical to this one.
  26.  
  27.    Permission is granted to copy and distribute translations of this
  28. manual into another language, under the above conditions for modified
  29. versions, except that this permission notice may be stated in a
  30. translation approved by the Foundation.
  31.  
  32. 
  33. File: libtool.info,  Node: Using Automake,  Next: Configuring,  Prev: Makefile rules,  Up: Integrating libtool
  34.  
  35. Using Automake with libtool
  36. ===========================
  37.  
  38.    Libtool library support is implemented under the `LTLIBRARIES'
  39. primary.
  40.  
  41.    Here are some samples from the Automake `Makefile.am' in the libtool
  42. distribution's `demo' subdirectory.
  43.  
  44.    First, to link a program against a libtool library, just use the
  45. `program_LDADD' variable:
  46.  
  47.      bin_PROGRAMS = hell hell.debug
  48.      
  49.      # Build hell from main.c and libhello.la
  50.      hell_SOURCES = main.c
  51.      hell_LDADD = libhello.la
  52.      
  53.      # Create an easier-to-debug version of hell.
  54.      hell_debug_SOURCES = main.c
  55.      hell_debug_LDADD = libhello.la
  56.      hell_debug_LDFLAGS = -static
  57.  
  58.    The flags `-dlopen' or `-dlpreopen' (*note Link mode::.) would fit
  59. better in the PROGRAM_LDADD variable.  Unfortunately, GNU automake, up
  60. to release 1.4, doesn't accept these flags in a PROGRAM_LDADD variable,
  61. so you have the following alternatives:
  62.  
  63.    * add them to PROGRAM_LDFLAGS, and list the libraries in
  64.      PROGRAM_DEPENDENCIES, then wait for a release of GNU automake that
  65.      accepts these flags where they belong;
  66.  
  67.    * surround the flags between quotes, but then you must set
  68.      PROGRAM_DEPENDENCIES too:
  69.  
  70.           program_LDADD = "-dlopen" libfoo.la
  71.           program_DEPENDENCIES = libfoo.la
  72.  
  73.    * set and `AC_SUBST' variables DLOPEN and DLPREOPEN in
  74.      `configure.in' and use `@DLOPEN@' and `@DLPREOPEN@' as
  75.      replacements for the explicit flags `-dlopen' and `-dlpreopen' in
  76.      `program_LDADD'.  Automake will discard `AC_SUBST'ed variables
  77.      from dependencies, so it will behave exactly as we expect it to
  78.      behave when it accepts these flags in `program_LDADD'.  But hey!,
  79.      this is ugly!
  80.  
  81.    You may use the `program_LDFLAGS' variable to stuff in any flags you
  82. want to pass to libtool while linking `program' (such as `-static' to
  83. avoid linking uninstalled shared libtool libraries).
  84.  
  85.    Building a libtool library is almost as trivial... note the use of
  86. `libhello_la_LDFLAGS' to pass the `-version-info' (*note Versioning::.)
  87. option to libtool:
  88.  
  89.      # Build a libtool library, libhello.la for installation in libdir.
  90.      lib_LTLIBRARIES = libhello.la
  91.      libhello_la_SOURCES = hello.c foo.c
  92.      libhello_la_LDFLAGS = -version-info 3:12:1
  93.  
  94.    The `-rpath' option is passed automatically by Automake (except for
  95. libraries listed as `noinst_LTLIBRARIES'), so you should not specify it.
  96.  
  97.    *Note Building a Shared Library: (automake)A Shared Library, for
  98. more information.
  99.  
  100. 
  101. File: libtool.info,  Node: Configuring,  Next: Distributing,  Prev: Using Automake,  Up: Integrating libtool
  102.  
  103. Configuring libtool
  104. ===================
  105.  
  106.    Libtool requires intimate knowledge of your compiler suite and
  107. operating system in order to be able to create shared libraries and
  108. link against them properly.  When you install the libtool distribution,
  109. a system-specific libtool script is installed into your binary
  110. directory.
  111.  
  112.    However, when you distribute libtool with your own packages (*note
  113. Distributing::.), you do not always know which compiler suite and
  114. operating system are used to compile your package.
  115.  
  116.    For this reason, libtool must be "configured" before it can be used.
  117. This idea should be familiar to anybody who has used a GNU `configure'
  118. script.  `configure' runs a number of tests for system features, then
  119. generates the `Makefiles' (and possibly a `config.h' header file),
  120. after which you can run `make' and build the package.
  121.  
  122.    Libtool has its own equivalent to the `configure' script, `ltconfig'.
  123.  
  124. * Menu:
  125.  
  126. * Invoking ltconfig::           `ltconfig' command line options.
  127. * ltconfig example::            Manually configuring a `libtool'.
  128. * AM_PROG_LIBTOOL::             Configuring `libtool' in `configure.in'.
  129.  
  130. 
  131. File: libtool.info,  Node: Invoking ltconfig,  Next: ltconfig example,  Up: Configuring
  132.  
  133. Invoking `ltconfig'
  134. -------------------
  135.  
  136.    `ltconfig' runs a series of configuration tests, then creates a
  137. system-specific `libtool' in the current directory.  The `ltconfig'
  138. program has the following synopsis:
  139.  
  140.      ltconfig [OPTION]... LTMAIN [HOST]
  141.  
  142. and accepts the following options:
  143.  
  144. `--debug'
  145.      Dump a trace of shell script execution to standard output.  This
  146.      produces a lot of output, so you may wish to pipe it to `less' (or
  147.      `more') or redirect to a file.
  148.  
  149. `--disable-shared'
  150.      Create a `libtool' that only builds static libraries.
  151.  
  152. `--disable-static'
  153.      Create a `libtool' that builds only shared libraries if they are
  154.      available.  If only static libraries can be built, then this flag
  155.      has no effect.
  156.  
  157. `--disable-fast-install'
  158.      On platforms in which installable executables, that are created by
  159.      default, are not suitable for execution in the build directory,
  160.      create a `libtool' that links executables that search for
  161.      uninstalled libraries by default, and relinks them at install
  162.      time.  It is ignored on platforms in which a single executable is
  163.      enough.
  164.  
  165. `--enable-dlopen'
  166.      Test whether some dlopening mechanism is supported.  If this flag
  167.      is not given, or no working dlopening mechanism is found, create a
  168.      `libtool' that performs dlpreopening of all dlopened modules.
  169.  
  170. `--help'
  171.      Display a help message and exit.
  172.  
  173. `--no-verify'
  174.      Do not use `config.sub' to verify that HOST is a valid canonical
  175.      host system name.
  176.  
  177. `--output=FILE'
  178.  
  179. `-o FILE'
  180.      Instead of creating a libtool script called `libtool', create one
  181.      called FILE.  This can be useful if you want to create libtool
  182.      scripts for cross-compilers, or you want to have more than one
  183.      libtool in the same directory.
  184.  
  185. `--quiet'
  186. `--silent'
  187.      Do not print informational messages when running configuration
  188.      tests.
  189.  
  190. `--srcdir=DIR'
  191.      Look for `config.guess' and `config.sub' in DIR.
  192.  
  193. `--version'
  194.      Print `ltconfig' version information and exit.
  195.  
  196. `--with-gcc'
  197.      Assume that the GNU C compiler will be used when invoking the
  198.      created `libtool' to compile and link object files.
  199.  
  200. `--with-gnu-ld'
  201.      Assume that the C compiler uses the GNU linker.
  202.  
  203. `--disable-lock'
  204.      Create a `libtool' that does not perform locking to ensure proper
  205.      parallel compilation if the C compiler does not support `-c' and
  206.      `-o' together.
  207.  
  208. `--cache-file=FILE'
  209.      Use this FILE as a cache for results of a few tests.  This is
  210.      usually `config.cache' used by `configure'.  By default, no cache
  211.      file is used.
  212.  
  213.    LTMAIN is the `ltmain.sh' shell script fragment that provides the
  214. basic libtool functionality (*note Distributing::.).
  215.  
  216.    HOST is the canonical host system name, which by default is guessed
  217. by running `config.guess'.
  218.  
  219.    `ltconfig' also recognizes the following environment variables:
  220.  
  221.  - Variable: CC
  222.      The C compiler that will be used by the generated `libtool'.  If
  223.      this is not set, `ltconfig' will look for `gcc' or `cc'.
  224.  
  225.  - Variable: CFLAGS
  226.      Compiler flags used to generate standard object files.  If this is
  227.      not set, `ltconfig' will not use any such flags.  It affects only
  228.      the way `ltconfig' runs tests, not the produced `libtool'.
  229.  
  230.  - Variable: CPPFLAGS
  231.      C preprocessor flags.  If this is not set, `ltconfig' will not use
  232.      any such flags.  It affects only the way `ltconfig' runs tests, not
  233.      the produced `libtool'.
  234.  
  235.  - Variable: LD
  236.      The system linker to use (if the generated `libtool' requires one).
  237.      If this is not set, `ltconfig' will try to find out what is the
  238.      linker used by CC.
  239.  
  240.  - Variable: LDFLAGS
  241.      The flags to be used by `ltconfig' when it links a program.  If
  242.      this is not set, `ltconfig' will not use any such flags.  It
  243.      affects only the way `ltconfig' runs tests, not the produced
  244.      `libtool'.
  245.  
  246.  - Variable: LIBS
  247.      The libraries to be used by `ltconfig' when it links a program.  If
  248.      this is not set, `ltconfig' will not use any such flags.  It
  249.      affects only the way `ltconfig' runs tests, not the produced
  250.      `libtool'.
  251.  
  252.  - Variable: NM
  253.      Program to use rather than checking for `nm'.
  254.  
  255.  - Variable: RANLIB
  256.      Program to use rather than checking for `ranlib'.
  257.  
  258.  - Variable: LN_S
  259.      A command that creates a link of a program, a soft-link if
  260.      possible, a hard-link otherwise.
  261.  
  262.  - Variable: DLLTOOL
  263.      Program to use rather than checking for `dlltool'.  Only meaningful
  264.      for Cygwin/MS-Windows.
  265.  
  266.  - Variable: OBJDUMP
  267.      Program to use rather than checking for `objdump'.  Only meaningful
  268.      for Cygwin/MS-Windows.
  269.  
  270.  - Variable: AS
  271.      Program to use rather than checking for `as'.  Only meaningful for
  272.      Cygwin/MS-Windows.
  273.  
  274. 
  275. File: libtool.info,  Node: ltconfig example,  Next: AM_PROG_LIBTOOL,  Prev: Invoking ltconfig,  Up: Configuring
  276.  
  277. Using `ltconfig'
  278. ----------------
  279.  
  280.    Here is a simple example of using `ltconfig' to configure libtool on
  281. a NetBSD/i386 1.2 system:
  282.  
  283.      burger$ ./ltconfig ltmain.sh
  284.      checking host system type... i386-unknown-netbsd1.2
  285.      checking for ranlib... ranlib
  286.      checking for gcc... gcc
  287.      checking whether we are using GNU C... yes
  288.      checking for gcc option to produce PIC... -fPIC -DPIC
  289.      checking for gcc option to statically link programs... -static
  290.      checking if ld is GNU ld... no
  291.      checking if ld supports shared libraries... yes
  292.      checking dynamic linker characteristics... netbsd1.2 ld.so
  293.      checking if libtool supports shared libraries... yes
  294.      checking whether to build shared libraries... yes
  295.      creating libtool
  296.      burger$
  297.  
  298.    This example shows how to configure `libtool' for cross-compiling to
  299. a i486 GNU/Hurd 0.1 system (assuming compiler tools reside in
  300. `/local/i486-gnu/bin'):
  301.  
  302.      burger$ export PATH=/local/i486-gnu/bin:$PATH
  303.      burger$ ./ltconfig ltmain.sh i486-gnu0.1
  304.      checking host system type... i486-unknown-gnu0.1
  305.      checking for ranlib... ranlib
  306.      checking for gcc... gcc
  307.      checking whether we are using GNU C... yes
  308.      checking for gcc option to produce PIC... -fPIC -DPIC
  309.      checking for gcc option to statically link programs... -static
  310.      checking if ld is GNU ld... yes
  311.      checking if GNU ld supports shared libraries... yes
  312.      checking dynamic linker characteristics... gnu0.1 ld.so
  313.      checking if libtool supports shared libraries... yes
  314.      checking whether to build shared libraries... yes
  315.      creating libtool
  316.      burger$
  317.  
  318. 
  319. File: libtool.info,  Node: AM_PROG_LIBTOOL,  Prev: ltconfig example,  Up: Configuring
  320.  
  321. The `AM_PROG_LIBTOOL' macro
  322. ---------------------------
  323.  
  324.    If you are using GNU Autoconf (or Automake), you should add a call to
  325. `AM_PROG_LIBTOOL' to your `configure.in' file.  This macro offers
  326. seamless integration between the `configure' script and `ltconfig':
  327.  
  328.  - Macro: AM_PROG_LIBTOOL
  329.      Add support for the `--enable-shared' and `--disable-shared'
  330.      `configure' flags.  Invoke `ltconfig' with the correct arguments
  331.      to configure the package (*note Invoking ltconfig::.).(1)
  332.  
  333.      By default, this macro turns on shared libraries if they are
  334.      available, and also enables static libraries if they don't
  335.      conflict with the shared libraries.  You can modify these defaults
  336.      by calling either the `AC_DISABLE_SHARED' or `AC_DISABLE_STATIC'
  337.      macros:
  338.  
  339.           # Turn off shared libraries during beta-testing, since they
  340.           # make the build process take too long.
  341.           AC_DISABLE_SHARED
  342.           AM_PROG_LIBTOOL
  343.  
  344.      The user may specify modified forms of the configure flags
  345.      `--enable-shared' and `--enable-static' to choose whether shared
  346.      or static libraries are built based on the name of the package.
  347.      For example, to have shared `bfd' and `gdb' libraries built, but
  348.      not shared `libg++', you can run all three `configure' scripts as
  349.      follows:
  350.  
  351.           trick$ ./configure --enable-shared=bfd,gdb
  352.  
  353.      In general, specifying `--enable-shared=PKGS' is the same as
  354.      configuring with `--enable-shared' every package named in the
  355.      comma-separated PKGS list, and every other package with
  356.      `--disable-shared'.  The `--enable-static=PKGS' flag behaves
  357.      similarly, but it uses `--enable-static' and `--disable-static'.
  358.      The same applies to the `--enable-fast-install=PKGS' flag, which
  359.      uses `--enable-fast-install' and `--disable-fast-install'.
  360.  
  361.      The package name `default' matches any packages which have not set
  362.      their name in the `PACKAGE' environment variable.
  363.  
  364.      This macro also sets the shell variable LIBTOOL_DEPS, that you can
  365.      use to automatically update the libtool script if it becomes
  366.      out-of-date.  In order to do that, add to your `configure.in':
  367.  
  368.           AM_PROG_LIBTOOL
  369.           AC_SUBST(LIBTOOL_DEPS)
  370.  
  371.      and, to `Makefile.in' or `Makefile.am':
  372.  
  373.           LIBTOOL_DEPS = @LIBTOOL_DEPS@
  374.           libtool: $(LIBTOOL_DEPS)
  375.                   $(SHELL) ./config.status --recheck
  376.  
  377.      If you are using GNU automake, you can omit the assignment, as
  378.      automake will take care of it.  You'll obviously have to create
  379.      some dependency on `libtool'.
  380.  
  381.  
  382.  - Macro: AC_LIBTOOL_DLOPEN
  383.      Enable checking for dlopen support. This macro should be used if
  384.      the package makes use of the `-dlopen' and `-dlpreopen' flags,
  385.      otherwise libtool will assume that the system does not support
  386.      dlopening.  The macro must be called *before* `AM_PROG_LIBTOOL'.
  387.  
  388.  - Macro: AC_LIBTOOL_WIN32_DLL
  389.      This macro should be used if the package has been ported to build
  390.      clean dlls on win32 platforms.  Usually this means that any
  391.      library data items are exported with `__declspec(dllexport)' and
  392.      imported with `__declspec(dllimport)'.  If this macro is not used,
  393.      libtool will assume that the package libraries are not dll clean
  394.      and will build only static libraries on win32 hosts.
  395.  
  396.      `AM_PROG_LIBTOOL' must be called *after* this macro, and provision
  397.      must be made to pass `-no-undefined' to `libtool' in link mode
  398.      from the package `Makefile'.  Naturally, passing `-no-undefined'
  399.      means that all the library symbols *really are* defined at link
  400.      time!
  401.  
  402.  - Macro: AC_DISABLE_FAST_INSTALL
  403.      Change the default behaviour for `AM_PROG_LIBTOOL' to disable
  404.      optimization for fast installation.  The user may still override
  405.      this default, depending on platform support, by specifying
  406.      `--enable-fast-install'.
  407.  
  408.  - Macro: AC_DISABLE_SHARED
  409.  - Macro: AM_DISABLE_SHARED
  410.      Change the default behaviour for `AM_PROG_LIBTOOL' to disable
  411.      shared libraries.  The user may still override this default by
  412.      specifying `--enable-shared'.
  413.  
  414.  - Macro: AC_DISABLE_STATIC
  415.  - Macro: AM_DISABLE_STATIC
  416.      Change the default behaviour for `AM_PROG_LIBTOOL' to disable
  417.      static libraries.  The user may still override this default by
  418.      specifying `--enable-static'.
  419.  
  420.    When you invoke the `libtoolize' program (*note Invoking
  421. libtoolize::.), it will tell you where to find a definition of
  422. `AM_PROG_LIBTOOL'.  If you use Automake, the `aclocal' program will
  423. automatically add `AM_PROG_LIBTOOL' support to your `configure' script.
  424.  
  425.    Nevertheless, it is advisable to include a copy of `libtool.m4' in
  426. `acinclude.m4', so that, even if `aclocal.m4' and `configure' are
  427. rebuilt for any reason, the appropriate libtool macros will be used.
  428. The alternative is to hope the user will have a compatible version of
  429. `libtool.m4' installed and accessible for `aclocal'.  This may lead to
  430. weird errors when versions don't match.
  431.  
  432.    ---------- Footnotes ----------
  433.  
  434.    (1) `AM_PROG_LIBTOOL' requires that you define the `Makefile'
  435. variable `top_builddir' in your `Makefile.in'.  Automake does this
  436. automatically, but Autoconf users should set it to the relative path to
  437. the top of your build directory (`../..', for example).
  438.  
  439. 
  440. File: libtool.info,  Node: Distributing,  Next: Static-only libraries,  Prev: Configuring,  Up: Integrating libtool
  441.  
  442. Including libtool in your package
  443. =================================
  444.  
  445.    In order to use libtool, you need to include the following files with
  446. your package:
  447.  
  448. `config.guess'
  449.      Attempt to guess a canonical system name.
  450.  
  451. `config.sub'
  452.      Canonical system name validation subroutine script.
  453.  
  454. `ltconfig'
  455.      Generate a libtool script for a given system.
  456.  
  457. `ltmain.sh'
  458.      A generic script implementing basic libtool functionality.
  459.  
  460.    Note that the libtool script itself should *not* be included with
  461. your package.  *Note Configuring::.
  462.  
  463.    You should use the `libtoolize' program, rather than manually
  464. copying these files into your package.
  465.  
  466. * Menu:
  467.  
  468. * Invoking libtoolize::         `libtoolize' command line options.
  469. * Autoconf .o macros::          Autoconf macros that set object file names.
  470.  
  471. 
  472. File: libtool.info,  Node: Invoking libtoolize,  Next: Autoconf .o macros,  Up: Distributing
  473.  
  474. Invoking `libtoolize'
  475. ---------------------
  476.  
  477.    The `libtoolize' program provides a standard way to add libtool
  478. support to your package.  In the future, it may implement better usage
  479. checking, or other features to make libtool even easier to use.
  480.  
  481.    The `libtoolize' program has the following synopsis:
  482.  
  483.      libtoolize [OPTION]...
  484.  
  485. and accepts the following options:
  486.  
  487. `--automake'
  488.      Work silently, and assume that Automake libtool support is used.
  489.  
  490.      `libtoolize --automake' is used by Automake to add libtool files to
  491.      your package, when `AM_PROG_LIBTOOL' appears in your
  492.      `configure.in'.
  493.  
  494. `--copy'
  495. `-c'
  496.      Copy files from the libtool data directory rather than creating
  497.      symlinks.
  498.  
  499. `--debug'
  500.      Dump a trace of shell script execution to standard output.  This
  501.      produces a lot of output, so you may wish to pipe it to `less' (or
  502.      `more') or redirect to a file.
  503.  
  504. `--dry-run'
  505. `-n'
  506.      Don't run any commands that modify the file system, just print them
  507.      out.
  508.  
  509. `--force'
  510. `-f'
  511.      Replace existing libtool files.  By default, `libtoolize' won't
  512.      overwrite existing files.
  513.  
  514. `--help'
  515.      Display a help message and exit.
  516.  
  517. `--ltdl'
  518.      Install libltdl in a subdirectory of your package.
  519.  
  520. `--ltdl-tar'
  521.      Add the file libltdl.tar.gz to your package.
  522.  
  523. `--version'
  524.      Print `libtoolize' version information and exit.
  525.  
  526.    If `libtoolize' detects an explicit call to `AC_CONFIG_AUX_DIR'
  527. (*note The Autoconf Manual: (autoconf)Input.) in your `configure.in', it
  528. will put the files in the specified directory.
  529.  
  530.    `libtoolize' displays hints for adding libtool support to your
  531. package, as well.
  532.  
  533. 
  534. File: libtool.info,  Node: Autoconf .o macros,  Prev: Invoking libtoolize,  Up: Distributing
  535.  
  536. Autoconf `.o' macros
  537. --------------------
  538.  
  539.    The Autoconf package comes with a few macros that run tests, then
  540. set a variable corresponding to the name of an object file.  Sometimes
  541. it is necessary to use corresponding names for libtool objects.
  542.  
  543.    Here are the names of variables that list libtool objects:
  544.  
  545.  - Variable: LTALLOCA
  546.      Substituted by `AC_FUNC_ALLOCA' (*note Particular Function Checks:
  547.      (autoconf)Particular Functions.).  Is either empty, or contains
  548.      `alloca.lo'.
  549.  
  550.  - Variable: LTLIBOBJS
  551.      Substituted by `AC_REPLACE_FUNCS' (*note Generic Function Checks:
  552.      (autoconf)Generic Functions.), and a few other functions.
  553.  
  554.    Unfortunately, the most recent version of Autoconf (2.12, at the
  555. time of this writing) does not have any way for libtool to provide
  556. support for these variables.  So, if you depend on them, use the
  557. following code immediately before the call to `AC_OUTPUT' in your
  558. `configure.in':
  559.  
  560.      LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/.lo/g'`
  561.      AC_SUBST(LTLIBOBJS)
  562.      LTALLOCA=`echo "$ALLOCA" | sed 's/\.o/.lo/g'`
  563.      AC_SUBST(LTALLOCA)
  564.      AC_OUTPUT(...)
  565.  
  566. 
  567. File: libtool.info,  Node: Static-only libraries,  Prev: Distributing,  Up: Integrating libtool
  568.  
  569. Static-only libraries
  570. =====================
  571.  
  572.    When you are developing a package, it is often worthwhile to
  573. configure your package with the `--disable-shared' flag, or to override
  574. the defaults for `AM_PROG_LIBTOOL' by using the `AM_DISABLE_SHARED'
  575. Autoconf macro (*note The `AM_PROG_LIBTOOL' macro: AM_PROG_LIBTOOL.).
  576. This prevents libtool from building shared libraries, which has several
  577. advantages:
  578.  
  579.    * compilation is twice as fast, which can speed up your development
  580.      cycle,
  581.  
  582.    * debugging is easier because you don't need to deal with any
  583.      complexities added by shared libraries, and
  584.  
  585.    * you can see how libtool behaves on static-only platforms.
  586.  
  587.    You may want to put a small note in your package `README' to let
  588. other developers know that `--disable-shared' can save them time.  The
  589. following example note is taken from the GIMP(1) distribution `README':
  590.  
  591.      The GIMP uses GNU Libtool in order to build shared libraries on a
  592.      variety of systems. While this is very nice for making usable
  593.      binaries, it can be a pain when trying to debug a program. For that
  594.      reason, compilation of shared libraries can be turned off by
  595.      specifying the `--disable-shared' option to `configure'.
  596.  
  597.    ---------- Footnotes ----------
  598.  
  599.    (1) GNU Image Manipulation Program, for those who haven't taken the
  600. plunge.  See `http://www.gimp.org/'.
  601.  
  602. 
  603. File: libtool.info,  Node: Versioning,  Next: Library tips,  Prev: Integrating libtool,  Up: Top
  604.  
  605. Library interface versions
  606. **************************
  607.  
  608.    The most difficult issue introduced by shared libraries is that of
  609. creating and resolving runtime dependencies.  Dependencies on programs
  610. and libraries are often described in terms of a single name, such as
  611. `sed'.  So, one may say "libtool depends on sed," and that is good
  612. enough for most purposes.
  613.  
  614.    However, when an interface changes regularly, we need to be more
  615. specific: "Gnus 5.1 requires Emacs 19.28 or above."  Here, the
  616. description of an interface consists of a name, and a "version number."
  617.  
  618.    Even that sort of description is not accurate enough for some
  619. purposes.  What if Emacs 20 changes enough to break Gnus 5.1?
  620.  
  621.    The same problem exists in shared libraries: we require a formal
  622. version system to describe the sorts of dependencies that programs have
  623. on shared libraries, so that the dynamic linker can guarantee that
  624. programs are linked only against libraries that provide the interface
  625. they require.
  626.  
  627. * Menu:
  628.  
  629. * Interfaces::                  What are library interfaces?
  630. * Libtool versioning::          Libtool's versioning system.
  631. * Updating version info::       Changing version information before releases.
  632. * Release numbers::             Breaking binary compatibility for aesthetics.
  633.  
  634. 
  635. File: libtool.info,  Node: Interfaces,  Next: Libtool versioning,  Up: Versioning
  636.  
  637. What are library interfaces?
  638. ============================
  639.  
  640.    Interfaces for libraries may be any of the following (and more):
  641.  
  642.    * global variables: both names and types
  643.  
  644.    * global functions: argument types and number, return types, and
  645.      function names
  646.  
  647.    * standard input, standard output, standard error, and file formats
  648.  
  649.    * sockets, pipes, and other inter-process communication protocol
  650.      formats
  651.  
  652.    Note that static functions do not count as interfaces, because they
  653. are not directly available to the user of the library.
  654.  
  655. 
  656. File: libtool.info,  Node: Libtool versioning,  Next: Updating version info,  Prev: Interfaces,  Up: Versioning
  657.  
  658. Libtool's versioning system
  659. ===========================
  660.  
  661.    Libtool has its own formal versioning system.  It is not as flexible
  662. as some, but it is definitely the simplest of the more powerful
  663. versioning systems.
  664.  
  665.    Think of a library as exporting several sets of interfaces,
  666. arbitrarily represented by integers.  When a program is linked against
  667. a library, it may use any subset of those interfaces.
  668.  
  669.    Libtool's description of the interfaces that a program uses is
  670. simple: it encodes the least and the greatest interface numbers in the
  671. resulting binary (FIRST-INTERFACE, LAST-INTERFACE).
  672.  
  673.    The dynamic linker is guaranteed that if a library supports *every*
  674. interface number between FIRST-INTERFACE and LAST-INTERFACE, then the
  675. program can be relinked against that library.
  676.  
  677.    Note that this can cause problems because libtool's compatibility
  678. requirements are actually stricter than is necessary.
  679.  
  680.    Say `libhello' supports interfaces 5, 16, 17, 18, and 19, and that
  681. libtool is used to link `test' against `libhello'.
  682.  
  683.    Libtool encodes the numbers 5 and 19 in `test', and the dynamic
  684. linker will only link `test' against libraries that support *every*
  685. interface between 5 and 19.  So, the dynamic linker refuses to link
  686. `test' against `libhello'!
  687.  
  688.    In order to eliminate this problem, libtool only allows libraries to
  689. declare consecutive interface numbers.  So, `libhello' can declare at
  690. most that it supports interfaces 16 through 19.  Then, the dynamic
  691. linker will link `test' against `libhello'.
  692.  
  693.    So, libtool library versions are described by three integers:
  694.  
  695. CURRENT
  696.      The most recent interface number that this library implements.
  697.  
  698. REVISION
  699.      The implementation number of the CURRENT interface.
  700.  
  701. AGE
  702.      The difference between the newest and oldest interfaces that this
  703.      library implements.  In other words, the library implements all the
  704.      interface numbers in the range from number `CURRENT - AGE' to
  705.      `CURRENT'.
  706.  
  707.    If two libraries have identical CURRENT and AGE numbers, then the
  708. dynamic linker chooses the library with the greater REVISION number.
  709.  
  710. 
  711. File: libtool.info,  Node: Updating version info,  Next: Release numbers,  Prev: Libtool versioning,  Up: Versioning
  712.  
  713. Updating library version information
  714. ====================================
  715.  
  716.    If you want to use libtool's versioning system, then you must specify
  717. the version information to libtool using the `-version-info' flag
  718. during link mode (*note Link mode::.).
  719.  
  720.    This flag accepts an argument of the form
  721. `CURRENT[:REVISION[:AGE]]'.  So, passing `-version-info 3:12:1' sets
  722. CURRENT to 3, REVISION to 12, and AGE to 1.
  723.  
  724.    If either REVISION or AGE are omitted, they default to 0.  Also note
  725. that AGE must be less than or equal to the CURRENT interface number.
  726.  
  727.    Here are a set of rules to help you update your library version
  728. information:
  729.  
  730.   1. Start with version information of `0:0:0' for each libtool library.
  731.  
  732.   2. Update the version information only immediately before a public
  733.      release of your software.  More frequent updates are unnecessary,
  734.      and only guarantee that the current interface number gets larger
  735.      faster.
  736.  
  737.   3. If the library source code has changed at all since the last
  738.      update, then increment REVISION (`C:R:A' becomes `C:r+1:A').
  739.  
  740.   4. If any interfaces have been added, removed, or changed since the
  741.      last update, increment CURRENT, and set REVISION to 0.
  742.  
  743.   5. If any interfaces have been added since the last public release,
  744.      then increment AGE.
  745.  
  746.   6. If any interfaces have been removed since the last public release,
  747.      then set AGE to 0.
  748.  
  749.    **Never** try to set the interface numbers so that they correspond
  750. to the release number of your package.  This is an abuse that only
  751. fosters misunderstanding of the purpose of library versions.  Instead,
  752. use the `-release' flag (*note Release numbers::.), but be warned that
  753. every release of your package will not be binary compatible with any
  754. other release.
  755.  
  756. 
  757. File: libtool.info,  Node: Release numbers,  Prev: Updating version info,  Up: Versioning
  758.  
  759. Managing release information
  760. ============================
  761.  
  762.    Often, people want to encode the name of the package release into the
  763. shared library so that it is obvious to the user which package their
  764. programs are linked against.  This convention is used especially on
  765. GNU/Linux:
  766.  
  767.      trick$ ls /usr/lib/libbfd*
  768.      /usr/lib/libbfd.a        /usr/lib/libbfd.so.2.7.0.2
  769.      /usr/lib/libbfd.so
  770.      trick$
  771.  
  772.    On `trick', `/usr/lib/libbfd.so' is a symbolic link to
  773. `libbfd.so.2.7.0.2', which was distributed as a part of
  774. `binutils-2.7.0.2'.
  775.  
  776.    Unfortunately, this convention conflicts directly with libtool's
  777. idea of library interface versions, because the library interface
  778. rarely changes at the same time that the release number does, and the
  779. library suffix is never the same across all platforms.
  780.  
  781.    So, in order to accomodate both views, you can use the `-release'
  782. flag in order to set release information for libraries which you do not
  783. want to use `-version-info'.  For the `libbfd' example, the next
  784. release which uses libtool should be built with `-release 2.9.0', which
  785. will produce the following files on GNU/Linux:
  786.  
  787.      trick$ ls /usr/lib/libbfd*
  788.      /usr/lib/libbfd-2.9.0.so     /usr/lib/libbfd.a
  789.      /usr/lib/libbfd.so
  790.      trick$
  791.  
  792.    In this case, `/usr/lib/libbfd.so' is a symbolic link to
  793. `libbfd-2.9.0.so'.  This makes it obvious that the user is dealing with
  794. `binutils-2.9.0', without compromising libtool's idea of interface
  795. versions.
  796.  
  797.    Note that this option causes a modification of the library name, so
  798. do not use it unless you want to break binary compatibility with any
  799. past library releases.  In general, you should only use `-release' for
  800. package-internal libraries or for ones whose interfaces change very
  801. frequently.
  802.  
  803. 
  804. File: libtool.info,  Node: Library tips,  Next: Inter-library dependencies,  Prev: Versioning,  Up: Top
  805.  
  806. Tips for interface design
  807. *************************
  808.  
  809.    Writing a good library interface takes a lot of practice and thorough
  810. understanding of the problem that the library is intended to solve.
  811.  
  812.    If you design a good interface, it won't have to change often, you
  813. won't have to keep updating documentation, and users won't have to keep
  814. relearning how to use the library.
  815.  
  816.    Here is a brief list of tips for library interface design, which may
  817. help you in your exploits:
  818.  
  819. Plan ahead
  820.      Try to make every interface truly minimal, so that you won't need
  821.      to delete entry points very often.
  822.  
  823. Avoid interface changes
  824.      Some people love redesigning and changing entry points just for
  825.      the heck of it (note: *renaming* a function is considered changing
  826.      an entry point).  Don't be one of those people.  If you must
  827.      redesign an interface, then try to leave compatibility functions
  828.      behind so that users don't need to rewrite their existing code.
  829.  
  830. Use opaque data types
  831.      The fewer data type definitions a library user has access to, the
  832.      better.  If possible, design your functions to accept a generic
  833.      pointer (which you can cast to an internal data type), and provide
  834.      access functions rather than allowing the library user to directly
  835.      manipulate the data.  That way, you have the freedom to change the
  836.      data structures without changing the interface.
  837.  
  838.      This is essentially the same thing as using abstract data types and
  839.      inheritance in an object-oriented system.
  840.  
  841. Use header files
  842.      If you are careful to document each of your library's global
  843.      functions and variables in header files, and include them in your
  844.      library source files, then the compiler will let you know if you
  845.      make any interface changes by accident (*note C header files::.).
  846.  
  847. Use the `static' keyword (or equivalent) whenever possible
  848.      The fewer global functions your library has, the more flexibility
  849.      you'll have in changing them.  Static functions and variables may
  850.      change forms as often as you like... your users cannot access
  851.      them, so they aren't interface changes.
  852.  
  853. * Menu:
  854.  
  855. * C header files::              How to write portable include files.
  856.  
  857. 
  858. File: libtool.info,  Node: C header files,  Up: Library tips
  859.  
  860. Writing C header files
  861. ======================
  862.  
  863.    Writing portable C header files can be difficult, since they may be
  864. read by different types of compilers:
  865.  
  866. C++ compilers
  867.      C++ compilers require that functions be declared with full
  868.      prototypes, since C++ is more strongly typed than C.  C functions
  869.      and variables also need to be declared with the `extern "C"'
  870.      directive, so that the names aren't mangled.  *Note C++
  871.      libraries::, for other issues relevant to using C++ with libtool.
  872.  
  873. ANSI C compilers
  874.      ANSI C compilers are not as strict as C++ compilers, but functions
  875.      should be prototyped to avoid unnecessary warnings when the header
  876.      file is `#include'd.
  877.  
  878. non-ANSI C compilers
  879.      Non-ANSI compilers will report errors if functions are prototyped.
  880.  
  881.    These complications mean that your library interface headers must use
  882. some C preprocessor magic in order to be usable by each of the above
  883. compilers.
  884.  
  885.    `foo.h' in the `demo' subdirectory of the libtool distribution
  886. serves as an example for how to write a header file that can be safely
  887. installed in a system directory.
  888.  
  889.    Here are the relevant portions of that file:
  890.  
  891.      /* __BEGIN_DECLS should be used at the beginning of your declarations,
  892.         so that C++ compilers don't mangle their names.  Use __END_DECLS at
  893.         the end of C declarations. */
  894.      #undef __BEGIN_DECLS
  895.      #undef __END_DECLS
  896.      #ifdef __cplusplus
  897.      # define __BEGIN_DECLS extern "C" {
  898.      # define __END_DECLS }
  899.      #else
  900.      # define __BEGIN_DECLS /* empty */
  901.      # define __END_DECLS /* empty */
  902.      #endif
  903.      
  904.      /* __P is a macro used to wrap function prototypes, so that compilers
  905.         that don't understand ANSI C prototypes still work, and ANSI C
  906.         compilers can issue warnings about type mismatches. */
  907.      #undef __P
  908.      #if defined (__STDC__) || defined (_AIX) \
  909.              || (defined (__mips) && defined (_SYSTYPE_SVR4)) \
  910.              || defined(WIN32) || defined(__cplusplus)
  911.      # define __P(protos) protos
  912.      #else
  913.      # define __P(protos) ()
  914.      #endif
  915.  
  916.    These macros are used in `foo.h' as follows:
  917.  
  918.      #ifndef _FOO_H_
  919.      #define _FOO_H_ 1
  920.      
  921.      /* The above macro definitions. */
  922.      ...
  923.      
  924.      __BEGIN_DECLS
  925.      int foo __P((void));
  926.      int hello __P((void));
  927.      __END_DECLS
  928.      
  929.      #endif /* !_FOO_H_ */
  930.  
  931.    Note that the `#ifndef _FOO_H_' prevents the body of `foo.h' from
  932. being read more than once in a given compilation.
  933.  
  934.    Feel free to copy the definitions of `__P', `__BEGIN_DECLS', and
  935. `__END_DECLS' into your own headers.  Then, you may use them to create
  936. header files that are valid for C++, ANSI, and non-ANSI compilers.
  937.  
  938.    Do not be naive about writing portable code.  Following the tips
  939. given above will help you miss the most obvious problems, but there are
  940. definitely other subtle portability issues.  You may need to cope with
  941. some of the following issues:
  942.  
  943.    * Pre-ANSI compilers do not always support the `void *' generic
  944.      pointer type, and so need to use `char *' in its place.
  945.  
  946.    * The `const' and `signed' keywords are not supported by some
  947.      compilers, especially pre-ANSI compilers.
  948.  
  949.    * The `long double' type is not supported by many compilers.
  950.  
  951. 
  952. File: libtool.info,  Node: Inter-library dependencies,  Next: Dlopened modules,  Prev: Library tips,  Up: Top
  953.  
  954. Inter-library dependencies
  955. **************************
  956.  
  957.    By definition, every shared library system provides a way for
  958. executables to depend on libraries, so that symbol resolution is
  959. deferred until runtime.
  960.  
  961.    An "inter-library dependency" is one in which a library depends on
  962. other libraries.  For example, if the libtool library `libhello' uses
  963. the `cos' function, then it has an inter-library dependency on `libm',
  964. the math library that implements `cos'.
  965.  
  966.    Some shared library systems provide this feature in an
  967. internally-consistent way: these systems allow chains of dependencies of
  968. potentially infinite length.
  969.  
  970.    However, most shared library systems are restricted in that they only
  971. allow a single level of dependencies.  In these systems, programs may
  972. depend on shared libraries, but shared libraries may not depend on other
  973. shared libraries.
  974.  
  975.    In any event, libtool provides a simple mechanism for you to declare
  976. inter-library dependencies: for every library `libNAME' that your own
  977. library depends on, simply add a corresponding `-lNAME' option to the
  978. link line when you create your library.(1)  To make an example of our
  979. `libhello' that depends on `libm':
  980.  
  981.      burger$ libtool gcc -g -O -o libhello.la foo.lo hello.lo \
  982.                      -rpath /usr/local/lib -lm
  983.      burger$
  984.  
  985.    When you link a program against `libhello', you don't need to
  986. specify the same `-l' options again: libtool will do that for you, in
  987. order to guarantee that all the required libraries are found.  This
  988. restriction is only necessary to preserve compatibility with static
  989. library systems and simple dynamic library systems.
  990.  
  991.    Some platforms, such as AIX, do not even allow you this flexibility.
  992. In order to build a shared library, it must be entirely self-contained
  993. (that is, have references only to symbols that are found in the `.lo'
  994. files or the specified `-l' libraries), and you need to specify the
  995. -NO-UNDEFINED flag.  By default, libtool builds only static libraries
  996. on these kinds of platforms.
  997.  
  998.    The simple-minded inter-library dependency tracking code of libtool
  999. releases prior to 1.2 was disabled because it was not clear when it was
  1000. possible to link one library with another, and complex failures would
  1001. occur.  A more complex implementation of this concept was re-introduced
  1002. before release 1.3, but it has not been ported to all platforms that
  1003. libtool supports.  The default, conservative behavior is to avoid
  1004. linking one library with another, introducing their inter-dependencies
  1005. only when a program is linked with them.
  1006.  
  1007.    ---------- Footnotes ----------
  1008.  
  1009.    (1) Unfortunately, as of libtool version 1.3.2, there is no way to
  1010. specify inter-library dependencies on libtool libraries that have not
  1011. yet been installed.  Libtool 1.4 will support this feature.
  1012.  
  1013. 
  1014. File: libtool.info,  Node: Dlopened modules,  Next: Using libltdl,  Prev: Inter-library dependencies,  Up: Top
  1015.  
  1016. Dlopened modules
  1017. ****************
  1018.  
  1019.    It can sometimes be confusing to discuss "dynamic linking", because
  1020. the term is used to refer to two different concepts:
  1021.  
  1022.   1. Compiling and linking a program against a shared library, which is
  1023.      resolved automatically at run time by the dynamic linker.  In this
  1024.      process, dynamic linking is transparent to the application.
  1025.  
  1026.   2. The application calling functions such as `dlopen',(1) which load
  1027.      arbitrary, user-specified modules at runtime.  This type of dynamic
  1028.      linking is explicitly controlled by the application.
  1029.  
  1030.    To mitigate confusion, this manual refers to the second type of
  1031. dynamic linking as "dlopening" a module.
  1032.  
  1033.    The main benefit to dlopening object modules is the ability to access
  1034. compiled object code to extend your program, rather than using an
  1035. interpreted language.  In fact, dlopen calls are frequently used in
  1036. language interpreters to provide an efficient way to extend the
  1037. language.
  1038.  
  1039.    As of version 1.3.2, libtool provides support for dlopened modules.
  1040. However, you should indicate that your package is willing to use such
  1041. support, by using the macro `AC_LIBTOOL_DLOPEN' in `configure.in'.  If
  1042. this macro is not used (or it is used *after* `AM_PROG_LIBTOOL'),
  1043. libtool will assume no dlopening mechanism is available, and will try
  1044. to simulate it.
  1045.  
  1046.    This chapter discusses how you as a dlopen application developer
  1047. might use libtool to generate dlopen-accessible modules.
  1048.  
  1049. * Menu:
  1050.  
  1051. * Building modules::            Creating dlopenable objects and libraries.
  1052. * Dlpreopening::                Dlopening that works on static platforms.
  1053. * Finding the dlname::          Choosing the right file to `dlopen'.
  1054. * Dlopen issues::               Unresolved problems that need your attention.
  1055.  
  1056.    ---------- Footnotes ----------
  1057.  
  1058.    (1) HP-UX, to be different, uses a function named `shl_load'.
  1059.  
  1060. 
  1061. File: libtool.info,  Node: Building modules,  Next: Dlpreopening,  Up: Dlopened modules
  1062.  
  1063. Building modules to dlopen
  1064. ==========================
  1065.  
  1066.    On some operating systems, a program symbol must be specially
  1067. declared in order to be dynamically resolved with the `dlsym' (or
  1068. equivalent) function.
  1069.  
  1070.    Libtool provides the `-export-dynamic' and `-module' link flags
  1071. (*note Link mode::.), which do this declaration.  You need to use these
  1072. flags if you are linking an application program that dlopens other
  1073. modules or a libtool library that will also be dlopened.
  1074.  
  1075.    For example, if we wanted to build a shared library, `libhello',
  1076. that would later be dlopened by an application, we would add `-module'
  1077. to the other link flags:
  1078.  
  1079.      burger$ libtool gcc -module -o libhello.la foo.lo \
  1080.                      hello.lo -rpath /usr/local/lib -lm
  1081.      burger$
  1082.  
  1083.    If symbols from your *executable* are needed to satisfy unresolved
  1084. references in a library you want to dlopen you will have to use the flag
  1085. `-export-dynamic'.  You should use `-export-dynamic' while linking the
  1086. executable that calls dlopen:
  1087.  
  1088.      burger$ libtool gcc -export-dynamic -o hell-dlopener main.o
  1089.      burger$
  1090.  
  1091. 
  1092. File: libtool.info,  Node: Dlpreopening,  Next: Finding the dlname,  Prev: Building modules,  Up: Dlopened modules
  1093.  
  1094. Dlpreopening
  1095. ============
  1096.  
  1097.    Libtool provides special support for dlopening libtool object and
  1098. libtool library files, so that their symbols can be resolved *even on
  1099. platforms without any `dlopen' and `dlsym' functions.*.
  1100.  
  1101.    Consider the following alternative ways of loading code into your
  1102. program, in order of increasing "laziness":
  1103.  
  1104.   1. Linking against object files that become part of the program
  1105.      executable, whether or not they are referenced.  If an object file
  1106.      cannot be found, then the linker refuses to create the executable.
  1107.  
  1108.   2. Declaring a static library to the linker, so that it is searched
  1109.      at link time in order to satisfy any undefined references in the
  1110.      above object files.  If the static library cannot be found, then
  1111.      the linker refuses to link the executable.
  1112.  
  1113.   3. Declaring a shared library to the runtime linker, so that it is
  1114.      searched at runtime in order to satisfy any undefined references
  1115.      in the above files.  If the shared library cannot be found, then
  1116.      the dynamic linker aborts the program before it runs.
  1117.  
  1118.   4. Dlopening a module, so that the application can resolve its own,
  1119.      dynamically-computed references.  If there is an error opening the
  1120.      module, or the module is not found, then the application can
  1121.      recover without crashing.
  1122.  
  1123.    Libtool emulates `-dlopen' on static platforms by linking objects
  1124. into the program at compile time, and creating data structures that
  1125. represent the program's symbol table.
  1126.  
  1127.    In order to use this feature, you must declare the objects you want
  1128. your application to dlopen by using the `-dlopen' or `-dlpreopen' flags
  1129. when you link your program (*note Link mode::.).
  1130.  
  1131.  - Structure: struct lt_dlsymlist { const char *NAME; lt_ptr_t ADDRESS;
  1132.           }
  1133.      The NAME attribute is a null-terminated character string of the
  1134.      symbol name, such as `"fprintf"'.  The ADDRESS attribute is a
  1135.      generic pointer to the appropriate object, such as `&fprintf'.
  1136.  
  1137.  - Variable: const lt_dlsymlist * lt_preloaded_symbols
  1138.      An array of LT_SYMBOL structures, representing all the preloaded
  1139.      symbols linked into the program. For each `-dlpreloaded' file
  1140.      there is an element with the NAME of the file and a ADDRESS of
  1141.      `0', followed by all symbols exported from this file.  For the
  1142.      executable itself the special name @PROGRAM@ is used.  The last
  1143.      element has a NAME and ADDRESS of `0'.
  1144.  
  1145.    Some compilers may allow identifiers which are not valid in ANSI C,
  1146. such as dollar signs.  Libtool only recognizes valid ANSI C symbols (an
  1147. initial ASCII letter or underscore, followed by zero or more ASCII
  1148. letters, digits, and underscores), so non-ANSI symbols will not appear
  1149. in LT_PRELOADED_SYMBOLS.
  1150.  
  1151. 
  1152. File: libtool.info,  Node: Finding the dlname,  Next: Dlopen issues,  Prev: Dlpreopening,  Up: Dlopened modules
  1153.  
  1154. Finding the correct name to dlopen
  1155. ==================================
  1156.  
  1157.    After a library has been linked with `-module', it can be dlopened.
  1158. Unfortunately, because of the variation in library names, your package
  1159. needs to determine the correct file to dlopen.
  1160.  
  1161.    The most straightforward and flexible implementation is to determine
  1162. the name at runtime, by finding the installed `.la' file, and searching
  1163. it for the following lines:
  1164.  
  1165.      # The name that we can `dlopen'.
  1166.      dlname='DLNAME'
  1167.  
  1168.    If DLNAME is empty, then the library cannot be dlopened.  Otherwise,
  1169. it gives the dlname of the library.  So, if the library was installed
  1170. as `/usr/local/lib/libhello.la', and the DLNAME was `libhello.so.3',
  1171. then `/usr/local/lib/libhello.so.3' should be dlopened.
  1172.  
  1173.    If your program uses this approach, then it should search the
  1174. directories listed in the `LD_LIBRARY_PATH'(1) environment variable, as
  1175. well as the directory where libraries will eventually be installed.
  1176. Searching this variable (or equivalent) will guarantee that your
  1177. program can find its dlopened modules, even before installation,
  1178. provided you have linked them using libtool.
  1179.  
  1180.    ---------- Footnotes ----------
  1181.  
  1182.    (1) `LIBPATH' on AIX, and `SHLIB_PATH' on HP-UX.
  1183.  
  1184. 
  1185. File: libtool.info,  Node: Dlopen issues,  Prev: Finding the dlname,  Up: Dlopened modules
  1186.  
  1187. Unresolved dlopen issues
  1188. ========================
  1189.  
  1190.    The following problems are not solved by using libtool's dlopen
  1191. support:
  1192.  
  1193.    * Dlopen functions are generally only available on shared library
  1194.      platforms.  If you want your package to be portable to static
  1195.      platforms, you have to use either libltdl (*note Using libltdl::.)
  1196.      or develop your own alternatives to dlopening dynamic code.  Most
  1197.      reasonable solutions involve writing wrapper functions for the
  1198.      `dlopen' family, which do package-specific tricks when dlopening
  1199.      is unsupported or not available on a given platform.
  1200.  
  1201.    * There are major differences in implementations of the `dlopen'
  1202.      family of functions.  Some platforms do not even use the same
  1203.      function names (notably HP-UX, with its `shl_load' family).
  1204.  
  1205.    * The application developer must write a custom search function in
  1206.      order to discover the correct module filename to supply to
  1207.      `dlopen'.
  1208.  
  1209. 
  1210. File: libtool.info,  Node: Using libltdl,  Next: Other languages,  Prev: Dlopened modules,  Up: Top
  1211.  
  1212. Using libltdl
  1213. *************
  1214.  
  1215.    Libtool provides a small library, called `libltdl', that aims at
  1216. hiding the various difficulties of dlopening libraries from programmers.
  1217. It consists of a header-file and a small C source file that can be
  1218. distributed with applications that need dlopening functionality.  On
  1219. some platforms, whose dynamic linkers are too limited for a simple
  1220. implementation of `libltdl' services, it requires GNU DLD, or it will
  1221. only emulate dynamic linking with libtool's dlpreopening mechanism.
  1222.  
  1223. libltdl supports currently the following dynamic linking mechanisms:
  1224.  
  1225.    * `dlopen' (Solaris, Linux and various BSD flavors)
  1226.  
  1227.    * `shl_load' (HP-UX)
  1228.  
  1229.    * `LoadLibrary' (Win16 and Win32)
  1230.  
  1231.    * `load_add_on' (BeOS)
  1232.  
  1233.    * GNU DLD (emulates dynamic linking for static libraries)
  1234.  
  1235.    * libtool's dlpreopen (see *note Dlpreopening::.)
  1236.  
  1237. libltdl is licensed under the terms of the GNU Library General Public
  1238. License, with the following exception:
  1239.  
  1240.      As a special exception to the GNU Library General Public License,
  1241.      if you distribute this file as part of a program that uses GNU
  1242.      libtool to create libraries and programs, you may include it under
  1243.      the same distribution terms that you use for the rest of that
  1244.      program.
  1245.  
  1246. * Menu:
  1247.  
  1248. * Libltdl interface::           How to use libltdl in your programs.
  1249. * Modules for libltdl::         Creating modules that can be `dlopen'ed.
  1250. * Distributing libltdl::        How to distribute libltdl with your package.
  1251.  
  1252.